package com.dq.controller.api.region;

import com.dq.domain.address.Address;
import com.dq.domain.org.Org;
import com.dq.domain.sys.user.user.base.SysUser;
import com.dq.exception.customException.ApiException;
import com.dq.service.AllService;
import com.dq.utils.BeanNullUtil;
import com.dq.vo.ListDataVo;
import com.dq.vo.Vo;
import com.dq.vo.baseVo.VO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.BeanUtils;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author cf
 */
@Api(description = "省市区管理")
@RestController
@RequestMapping("/api/login/address")
public class ApiRegionController extends AllService {
    @ApiOperation("省列表")
    @GetMapping("/province")
    public ListDataVo provinceList() {
        List<String> list = dao.find(String.format("SELECT u.province FROM Org u WHERE deleted = false GROUP BY  u.province order by u.province desc "));

        return new ListDataVo(list);
    }
    @ApiOperation("市列表")
    @GetMapping("/city/{province}")
    public ListDataVo cityList(@PathVariable String province) {
        List<String> list = dao.find(String.format("SELECT u.city FROM Org u WHERE deleted = false and u.province = '%s' GROUP BY u.city order by u.city desc ", province));

        return new ListDataVo(list);
    }
}
